package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConstant;
import com.itheima.entity.Result;
import com.itheima.pojo.CheckItem;
import com.itheima.service.CheckItemService;
import org.apache.log4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/checkitem")
public class TestController {
    private Logger logger = Logger.getLogger(TestController.class);

    @Reference
    private CheckItemService checkItemService;

    ///checkitem/add.do?name=aaa&&code=bbb
    @RequestMapping("/add2")
    public Result add(@RequestBody CheckItem checkItem){
        //通过dubbo调用远程接口
        try{
            checkItemService.add(checkItem);
        }catch (Exception e){
            logger.error(e);
            return new Result(false, MessageConstant.ADD_CHECKITEM_FAIL);
        }
        return new Result(true, MessageConstant.ADD_CHECKITEM_SUCCESS);
    }
}
